/*
 * spectrum.cpp
 *
 *  Created on: Jun 10, 2011
 *      Author: nzhao
 */
#include "core/globalvar.h"
#include "share/Usrdef.h"
#include "special/spectrum.h"
#include "core/Noise.h"
#include "share/parameters.h"

double SpectrumFunction(double freq, double b0, double tauC);

void Generate_Power_List()
{
	int i;
	double freq;

	POWER_LIST = new double [NFREQ];
	for(i = 0; i < NFREQ; i++)
	{
		freq = i * FREQ_STEP;
		POWER_LIST[i] = sqrt(2.0 * FREQ_STEP ) * NOISE_AMPLITUDE
				* SpectrumFunction(freq, NOISE_AMPLITUDE, CORRELATION_TIME);
//		cout << freq << "\t" << POWER_LIST[i] << endl;
	}
//	cout << endl;


//	char amp_file[200];
//
//	strcpy(amp_file, WORKSHOP);
//	strcat(amp_file, DEBUG_PATH);
//	strcat(amp_file, "Spect_");
//	strcat(amp_file, PARA_CHAR);
//	strcat(amp_file, ".dat");
//
//	ofstream amp(amp_file);
//	if(!amp) assert(0);
//
//	for(i = 0; i < NFREQ; i++)
//	{
//		freq = i * FREQ_STEP;
//		amp << freq << "\t" << POWER_LIST[i] << endl;
//	}
//	amp.close();
}


double SpectrumFunction(double freq, double b0, double tauC)
{
	double res, gammaC;

	gammaC	= 1.0 / tauC;

	res = sqrt( gammaC/ M_PI / ( gammaC * gammaC + freq * freq) );

	return(res);
}
